import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [{
    path: '/cart',
    name: 'Cart',
    meta: { //元信息设置
      requireAuth: true
    },
    component: () => import('@/views/Cart.vue')
  },
  {
    path: '/my',
    name: 'my',
    component: () => import('@/views/My.vue')
  },
  {
    path: '/loginout',
    name: 'loginout',
    component: () => import('@/views/login/loginout.vue'),
  },
  {
    path: '/login',
    component: () => import('@/views/login/Login.vue'),
    children: [{
        path: '/login/phone',
        name: 'phone',
        component: () => import('@/views/login/phone.vue'),
      },
      {
        path: '/login/user',
        name: 'user',
        component: () => import('@/views/login/user.vue'),
      },
      {
        path: "",
        redirect: "/login/phone" //进行一级路由内部的重定向操作 
      }
    ]
  },
  {
    path: '/',
    name: 'Home',
    component: () => import('@/views/Home.vue')
  },
  {
    path: '/product',
    name: 'Product',
    component: () => import('@/views/Product.vue')
  },
  {
    path: '/product/productlist',
    neme: 'productList',
    component: () => import('@/views/productList.vue')
  },
  {
    path: '/product/productlist/item',
    neme: 'item',
    component: () => import('@/views/item.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router